package com.example.bbook.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.bbook.util.HashMapTool;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.HashMap;

@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("u_goods")
public class GoodsEntity extends BaseEntity {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    private Integer userId;

    private String name;
    private Integer price;
    private Integer isDel;
    private String remark;
    private String cover;
    private Integer speciesId;
    private Integer inventory;
    private Integer total;

    @TableField(exist = false)
    private SpeciesEntity species;
    @TableField(exist = false)
    private UserEntity user;
    @TableField(exist = false)
    private SpeciesEntity goodsStatus;

    public GoodsEntity() {
        setColumns(new ArrayList<>());
        push("id", "number", "ID", new int[]{1, 1, 1, 0})
                .push("name", "string", "商品名", new int[]{1, 1, 1, 1})
                .push("price", "number", "商品价格", new int[]{1, 1, 1, 0})
                .push("remark", "text", "商品简介", new int[]{1, 1, 1, 0})
                .push("cover", "image", "商品封面", new int[]{1, 1, 1, 0})
                .push("inventory", "number", "商品库存", new int[]{1, 1, 1, 1})
                .push("total", "number", "商品总量", new int[]{1, 1, 1, 0});
    }

    public ArrayList<HashMap<String, Object>> thisColumns() {
        return getColumns();
    }
}
